package me.zk.practice1.s;

import org.apache.commons.math3.analysis.function.Max;

import java.util.*;

/**
 * @author zhangkai
 * @date 2023/8/9 17:42
 */
public class LS318 {

    public static void main(String[] args) {
        maxProduct(new String[]{"abcw","baz","foo","bar","xtfn","abcdef"});
    }
    public static int maxProduct(String[] words) {
        int max = 0,idx=0;
        int n = words.length;
        int[] masks = new int[n];
        for (String s : words) {
            int t=0;
            for (int i = 0; i < s.length(); i++) {
                int u = s.charAt(i)-'a';
                t|=(1<<u);
            }
            masks[idx++]=t;
        }
        for (int i = 0; i < masks.length-1; i++) {
            for (int j = 1; j < masks.length; j++) {
                if ((masks[i] & masks[j]) == 0) {
                    max = Math.max(max,words[i].length()*words[j].length());
                }
            }
        }

        return max;

    }
}
